<template>
    <section>
        <div class="col-bg clearfix">
            <div class="grid-content bg-purple" :style="{backgroundColor:titleColor}">
                 <div class="dev-title">平台设置</div>
            </div>
             
                  <el-form ref="form"   label-width="80px" style="margin:20px;width:80%;">
                      <el-form-item  label="平台名称">
                          <el-input auto-complete="off" v-model="platname.remark" :disabled="platnameDisabled" style="width:50%;"></el-input>
                          <span class="confirm" v-show="platnameVisible" @click="Submit('平台名称')">确认</span>
                           <i @click="changeState('平台名称')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                      </el-form-item>
                      <!-- <el-form-item  label="平台Logo" >
                           <el-input auto-complete="off" v-model="platlogo.remark" :disabled="platlogoDisabled" style="width:50%;"></el-input>
                           <span class="confirm" v-show="platlogoVisible" @click="Submit('平台Logo')">确认</span>
                           <i @click="changeState('平台Logo')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                      </el-form-item> -->
                      <el-form-item label="平台Logo">
                        <el-upload class="avatar-uploader" :headers="fileList" action="/api/auth/image_file/upload"
                            :show-file-list="false" :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
                            <img v-if="platlogo.remark" :src="platlogo.remark" class="avatar">
                            <i v-else class="el-icon-plus avatar-uploader-icon"></i> 
                        </el-upload>
                        <!-- <span class="confirm" v-show="platlogoVisible" @click="Submit('平台Logo')">确认</span> -->
                    </el-form-item>
                      <el-form-item  label="平台域名" >
                           <el-input auto-complete="off" v-model="platdomain.remark" :disabled="platdomainDisabled" style="width:50%;"></el-input>
                           <span class="confirm" v-show="platdomainVisible" @click="Submit('平台域名')">确认</span>
                           <i @click="changeState('平台域名')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                      </el-form-item>
                      <el-form-item  label="域名备案" >
                           <el-input auto-complete="off" v-model="platicp.remark" :disabled="platicpDisabled" style="width:50%;"></el-input>
                           <span class="confirm" v-show="platicpVisible" @click="Submit('域名备案')">确认</span>
                           <i @click="changeState('域名备案')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                      </el-form-item>
                      <el-form-item  label="维护电话" >
                           <el-input auto-complete="off" v-model="warningphone.remark" :disabled="warningphoneDisabled" style="width:50%;"></el-input>
                           <span class="confirm" v-show="warningphoneVisible" @click="Submit('维护电话')">确认</span>
                           <i @click="changeState('维护电话')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                      </el-form-item>
                  </el-form>
             </div>
             <div class="col-bg clearfix">
                <div class="grid-content bg-purple" :style="{backgroundColor:titleColor}">
                    <div class="dev-title">其他设置</div>
                </div>
                <div style="padding-left: 20px;padding-bottom: 20px;">
                    <!-- <el-tabs v-model="activeName">
                        <el-tab-pane label="百度短信" name="baidu">
                            <div class="other-setting">
                                <div class="other-setting-title">APPId:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="accessKeyId.remark" :disabled="accessKeyIdDisabled" style="width:80%;"></el-input>
                                    <span class="confirm" v-show="accessKeyIdVisible" @click="Submit('APPId')">确认</span>
                                    <i @click="changeState('APPId')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">SecretKey:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="secretAccessKy.remark" :disabled="secretAccessKyDisabled" style="width:80%;"></el-input>
                                    <span class="confirm" v-show="secretAccessKyVisible" @click="Submit('SecretKey')">确认</span>
                                    <i @click="changeState('SecretKey')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">设备告警模板:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="templateCodeAlarmDevice.remark" :disabled="templateCodeAlarmDeviceDisabled" style="width:80%;"></el-input>
                                    <span class="confirm" v-show="templateCodeAlarmDeviceVisible" @click="Submit('templateCodeAlarmDevice')">确认</span>
                                    <i @click="changeState('templateCodeAlarmDevice')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">服务器告警模板:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="templateCodeAlarmServer.remark" :disabled="templateCodeAlarmServerDisabled" style="width:80%;"></el-input>
                                    <span class="confirm" v-show="templateCodeAlarmServerVisible" @click="Submit('templateCodeAlarmServer')">确认</span>
                                    <i @click="changeState('templateCodeAlarmServer')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">验证码模板:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="templateCodeVerify.remark" :disabled="templateCodeVerifyDisabled" style="width:80%;"></el-input>
                                    <span class="confirm" v-show="templateCodeVerifyVisible" @click="Submit('TemplateCode')">确认</span>
                                    <i @click="changeState('TemplateCode')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">签名ID:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="invokeId.remark" :disabled="invokeIdDisabled" style="width:80%;"></el-input>
                                    <span class="confirm" v-show="invokeIdVisible" @click="Submit('invokeId')">确认</span>
                                    <i @click="changeState('invokeId')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                                </div>
                            </div>
                        </el-tab-pane>
                        <el-tab-pane label="微信公众号" name="weixin">
                            <div class="other-setting">
                                <div class="other-setting-title">名称:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="weixin_msg.mpName" :disabled="mpNameDisabled" style="width:80%;"></el-input>
                                    <span class="confirm" v-show="mpNameVisible" @click="SubmitWeixin('mpName')">确认</span>
                                    <i @click="changeState('mpName')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">AppKey:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="weixin_msg.appId" :disabled="AppKeyDisabled" style="width:80%;"></el-input>
                                    <span class="confirm" v-show="AppKeyVisible" @click="SubmitWeixin('AppKey')">确认</span>
                                    <i @click="changeState('AppKey')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">SecretKey:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="weixin_msg.appSecret" :disabled="SecretKey2Disabled" style="width:80%;"></el-input>
                                    <span class="confirm" v-show="SecretKey2Visible" @click="SubmitWeixin('SecretKey2')">确认</span>
                                    <i @click="changeState('SecretKey2')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">网址:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="weixin_msg.mpUrl" :disabled="SecretKey2Disabled" style="width:80%;"></el-input>
                                    <span class="confirm" v-show="SecretKey2Visible" @click="SubmitWeixin('mpUrl')">确认</span>
                                    <i @click="changeState('mpUrl')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">告警通知模板ID:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="weixin_msg.templateId" :disabled="templateIdDisabled" style="width:80%;"></el-input>
                                    <span class="confirm" v-show="templateIdVisible" @click="SubmitWeixin('templateId')">确认</span>
                                    <i @click="changeState('templateId')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">故障模板:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="weixin_msg.templateId2" :disabled="templateId2Disabled" style="width:80%;"></el-input>
                                    <span class="confirm" v-show="templateId2Visible" @click="SubmitWeixin('templateId2')">确认</span>
                                    <i @click="changeState('templateId2')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">注册模板:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="weixin_msg.templateId3" :disabled="templateId3Disabled" style="width:80%;"></el-input>
                                    <span class="confirm" v-show="templateId3Visible" @click="SubmitWeixin('templateId3')">确认</span>
                                    <i @click="changeState('templateId3')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">工单模板:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="weixin_msg.templateId4" :disabled="templateId4Disabled" style="width:80%;"></el-input>
                                    <span class="confirm" v-show="templateId4Visible" @click="SubmitWeixin('templateId4')">确认</span>
                                    <i @click="changeState('templateId4')" title="编辑" icon="el-icon-edit" circle class="pb-icon icon-edit"></i>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">二维码:</div>
                                <div>
                                    <el-upload class="avatar-uploader" :headers="fileList" action="/api/auth/image_file/upload"
                                        :show-file-list="false" :on-success="mpQrcodeSuccess" :before-upload="beforeAvatarUpload">
                                        <img v-if="weixin_msg.mpQrcode" :src="weixin_msg.mpQrcode" style="width:130px;" class="avatar">
                                        <i v-else class="el-icon-plus avatar-uploader-icon"></i>
                                    </el-upload>
                                </div>
                            </div>
                        </el-tab-pane>
                        <el-tab-pane label="license" name="license">
                            <div class="other-setting">
                                <div class="other-setting-title">序列号:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="licsn" :disabled="true" style="width:80%;"></el-input>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">有效期:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="exptime" :disabled="true" style="width:80%;"></el-input>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">最大设备数量:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="licdevmax"  :disabled="true" style="width:80%;"></el-input>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">证书状态:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="stateText"  :disabled="true" style="width:80%;"></el-input>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">被授权:</div>
                                <div>
                                    <el-input auto-complete="off" v-model="userName"  :disabled="true" style="width:80%;"></el-input>
                                </div>
                            </div>
                            <div class="other-setting">
                                <div class="other-setting-title">证书:</div>
                                <div>
                                    <el-button @click="checkLicense">查看证书</el-button>
                                </div>
                            </div>
                        </el-tab-pane>
                    </el-tabs> -->
                </div>
             </div>
             <el-dialog title="证书内容" v-show="editlicenseVisible"  @close="editlicenseVisible=false">
                <div slot="footer" style="text-align: left; ">
                    <div style="margin:10px 0;">
                        <el-input :rows="10" type="textarea" auto-complete="off" v-model="licenseText"></el-input>
                    </div>
                    <div slot="footer" class="dialog-footer" style="text-align: center;">
                        <el-button @click.native="editlicenseVisible = false">取消</el-button>
                        <el-button :type="buttonColor" @click="editSubmit"  :loading="editLoading">上传证书</el-button>
                    </div>
                </div>
            </el-dialog>
    </section>
</template>

<script>
    import {
        dict_query,
        dict_put,
        get_certificate,
        license_query,
        license_edit,
        company_weixin_my,
        company_weixin_put,
        dict_sys_query,
        dict_sys_put
    } from '../../api/api';
    export default {
        data(){
            return{
                activeName:'baidu',
                custom_version: this.CustomVersion(),//为0正常公有云，为1私有化定制
                platnameDisabled:true,
                platlogoDisabled:true,
                platicpDisabled:true,
                warningphoneDisabled:true,
                platdomainDisabled:true,
                accessKeyIdDisabled:true,
                secretAccessKyDisabled:true,
                templateCodeVerifyDisabled:true,
                AppKeyDisabled: true,
                SecretKey2Disabled: true,
                templateIdDisabled: true,
                mpNameDisabled:true,
                templateId2Disabled: true,
                templateId3Disabled: true,
                templateId4Disabled: true,
                invokeIdDisabled: true,
                templateCodeAlarmDeviceDisabled:true,
                templateCodeAlarmServerDisabled:true,
                
                platnameVisible:false,
                platlogoVisible:false,
                platicpVisible:false,
                warningphoneVisible:false,
                platdomainVisible:false,
                accessKeyIdVisible:false,
                secretAccessKyVisible:false,
                templateCodeVerifyVisible:false,
                AppKeyVisible: false,
                SecretKey2Visible: false,
                templateIdVisible: false,
                mpNameVisible: false,
                templateId2Visible: false,
                templateId3Visible: false,
                templateId4Visible: false,
                invokeIdVisible: false,
                templateCodeAlarmDeviceVisible: false,
                templateCodeAlarmServerVisible: false,
                
                editlicenseVisible:false,
                editLoading:false,
                platname:'',//名称
                platlogo:'',//图片logo
                platicp:'',//备案
                warningphone:'',//维护电话
                platdomain:'',//域名
                licsn:'',//序列号
                exptime:'',//有效期
                licdevmax:'',//最大设备量
                accessKeyId:'',//App Id
                secretAccessKy:'',//Secret Key
                templateCodeVerify:'',//TemplateCode
                invokeId:'',
                templateCodeAlarmDevice:'',//设备告警模板
                templateCodeAlarmServer:'',//服务器告警模板
                stateText:'', //证书状态
                licenseText:'',//证书内容
                userName:'',//被授权
                weixin_msg:[],
                fileList: {
                    token: JSON.parse(localStorage.getItem('key'))
                },
                isSMSshow:false,
                islicenseshow:false,
                weixinshow: false,
                baidumsg: "详情",
                licensemsg: "详情",
                weixinmsg: "详情"
            }
        },
        computed:{
            buttonColor(){
                return this.$store.state.buttonColor
            },
            titleColor(){
                return this.$store.state.titleColor
            },
            dialogTitleColor(){
                return this.$store.state.dialogTitleColor
            },
        },
        methods:{
            showbaidu(){
                this.isSMSshow = !this.isSMSshow
                if(this.isSMSshow == false){
                    this.baidumsg = "详情"
                }else{
                    this.baidumsg = "收起"
                }
            },
            showlicense(){
                this.islicenseshow = !this.islicenseshow
                if(this.islicenseshow == false){
                    this.licensemsg = "详情"
                }else{
                    this.licensemsg = "收起"
                }
            },
            showweixin(){
                this.weixinshow = !this.weixinshow
                if(this.weixinshow == false){
                    this.weixinmsg = "详情"
                }else{
                    this.weixinmsg = "收起"
                }
            },
            getUsers(){
                let para = {
                    pageNo: 1,
                    pageSize: 10,
                    name:'sys-conf'
                };
                dict_sys_query(para).then((res) => { 
                    console.log(res)
                    if(res.code == 0){
                        this.begCode (res.code);
                        let plat_name = res.data.find(item => {
                            return item.value == 'plat_name'
                        })
                        this.platname = plat_name;
                        let plat_logo = res.data.find(item => {
                            return item.value == 'plat_logo'
                        })
                        this.platlogo = plat_logo;
                        let plat_icp = res.data.find(item => {
                            return item.value == 'plat_icp'
                        })
                        this.platicp = plat_icp;
                        let warning_phone = res.data.find(item => {
                            return item.value == 'warning_phone'
                        })
                        this.warningphone = warning_phone
                        let plat_domain = res.data.find(item => {
                            return item.value == 'plat_domain'
                        })
                        this.platdomain = plat_domain;
                    }
                    });
                let para1 = {
                pageNo: 1,
                pageSize: 10,
                name:'baidu_sms'
                };
                dict_query(para1).then((res) => { 
                    if(res.code == 0){
                        this.begCode (res.code);
                        let accessKeyId1 = res.data.list.find(item => {
                            return item.value == 'accessKeyId'
                        })
                        this.accessKeyId = accessKeyId1;
                        let secretAccessKy1 = res.data.list.find(item => {
                            return item.value == 'secretAccessKy'
                        })
                        this.secretAccessKy = secretAccessKy1;
                        let templateCodeVerify1 = res.data.list.find(item => {
                            return item.value == 'templateCodeVerify'
                        })
                        this.templateCodeVerify = templateCodeVerify1;

                        let invokeId1 = res.data.list.find(item => {
                            return item.value == 'invokeId'
                        })
                        this.invokeId = invokeId1
                        let templateCodeAlarmDevice = res.data.list.find(item => {
                            return item.value == 'templateCodeAlarmDevice'
                        })
                        this.templateCodeAlarmDevice = templateCodeAlarmDevice
                        let templateCodeAlarmServer = res.data.list.find(item => {
                            return item.value == 'templateCodeAlarmServer'
                        })
                        this.templateCodeAlarmServer = templateCodeAlarmServer
                        // this.accessKeyId = res.data.list[0];
                        // this.secretAccessKy = res.data.list[1];
                        // this.templateCodeVerify = res.data.list[2];
                    }
                });
            },
            changeState(name){
                if(name == '平台名称'){
                    this.platnameDisabled = false;
                    this.platnameVisible = true
                }else
                if(name == '平台Logo'){
                    this.platlogoDisabled = false;
                    this.platlogoVisible = true
                }else
                if(name == '平台域名'){
                    this.platdomainDisabled = false;
                    this.platdomainVisible = true
                }else
                if(name == '域名备案'){
                    this.platicpDisabled = false;
                    this.platicpVisible = true
                }else
                if(name == '维护电话'){
                    this.warningphoneDisabled = false;
                    this.warningphoneVisible = true
                }else
                if(name == 'APPId'){
                    this.accessKeyIdDisabled = false;
                    this.accessKeyIdVisible = true
                }else
                if(name == 'SecretKey'){
                    this.secretAccessKyDisabled = false;
                    this.secretAccessKyVisible = true
                }else
                if(name == 'TemplateCode'){
                    this.templateCodeVerifyDisabled = false;
                    this.templateCodeVerifyVisible = true
                }else
                if(name == 'AppKey'){
                    this.AppKeyDisabled = false;
                    this.AppKeyVisible = true
                }else
                if(name == 'SecretKey2'){
                    this.SecretKey2Disabled = false;
                    this.SecretKey2Visible = true
                }else
                if(name == 'templateId'){
                    this.templateIdDisabled = false;
                    this.templateIdVisible = true
                }else 
                if(name == 'mpName'){
                    this.mpNameDisabled = false;
                    this.mpNameVisible = true
                }else 
                if(name == 'templateId2'){
                    this.templateId2Disabled = false;
                    this.templateId2Visible = true
                }else 
                if(name == 'templateId3'){
                    this.templateId3Disabled = false;
                    this.templateId3Visible = true
                }else 
                if(name == 'templateId4'){
                    this.templateId4Disabled = false;
                    this.templateId4Visible = true
                }else 
                if(name == 'invokeId'){
                    this.invokeIdDisabled = false;
                    this.invokeIdVisible = true
                }else 
                if(name == 'templateCodeAlarmDevice'){
                    this.templateCodeAlarmDeviceDisabled = false;
                    this.templateCodeAlarmDeviceVisible = true
                }else 
                if(name == 'templateCodeAlarmServer'){
                    this.templateCodeAlarmServerDisabled = false;
                    this.templateCodeAlarmServerVisible = true
                } 
                
            },
            Submit(name){
                var para
                if(name == '平台名称'){
                    if(this.platname.remark.length > 18 || this.platname.remark.length < 1){
                        this.$message({
                            message:'平台名称长度在 1 到 18 个字符',
                            type:'warning'
                        })
                        return false
                    }else{
                        this.platnameDisabled = true;
                        this.platnameVisible = false
                        localStorage.setItem('titleName',this.platname.remark)
                        document.title = this.platname.remark
                        para = Object.assign({}, this.platname);
                    }
                }else
                if(name == '平台Logo'){
                    // this.platlogoDisabled = true;
                    // this.platlogoVisible = false
                    para = Object.assign({}, this.platlogo);
                }else
                if(name == '平台域名'){
                    this.platdomainDisabled = true;
                    this.platdomainVisible = false
                    para = Object.assign({}, this.platdomain);
                }else
                if(name == '域名备案'){
                    this.platicpDisabled = true;
                    this.platicpVisible = false
                    para = Object.assign({}, this.platicp);
                }else
                if(name == '维护电话'){
                    this.warningphoneDisabled = true;
                    this.warningphoneVisible = false
                    para = Object.assign({}, this.warningphone);
                }else
                if(name == 'APPId'){
                    this.accessKeyIdDisabled = true;
                    this.accessKeyIdVisible = false
                    para = Object.assign({}, this.accessKeyId);
                }else
                if(name == 'SecretKey'){
                    this.secretAccessKyDisabled = true;
                    this.secretAccessKyVisible = false
                    para = Object.assign({}, this.secretAccessKy);
                }else
                if(name == 'TemplateCode'){
                    this.templateCodeVerifyDisabled = true;
                    this.templateCodeVerifyVisible = false
                    para = Object.assign({}, this.templateCodeVerify);
                }else
                if(name == 'invokeId'){
                    this.invokeIdDisabled = true;
                    this.invokeIdVisible = false
                    para = Object.assign({}, this.invokeId);
                }else
                if(name == 'templateCodeAlarmDevice'){
                    this.templateCodeAlarmDeviceDisabled = true;
                    this.templateCodeAlarmDeviceVisible = false
                    para = Object.assign({}, this.templateCodeAlarmDevice);
                }else
                if(name == 'templateCodeAlarmServer'){
                    this.templateCodeAlarmServerDisabled = true;
                    this.templateCodeAlarmServerVisible = false
                    para = Object.assign({}, this.templateCodeAlarmServer);
                }
                console.log(para)
                dict_sys_put(para).then((res) => { 
                    this.begCode (res.code); 
                    if (res.code == 0) {
                        this.editLoading = false;
                        //NProgress.done();
                        this.$message({
                            message: '修改成功',
                            type: 'success'
                        });
                        this.getUsers();
                        this.$emit('fatherMethod')
                    }
                });
            },
            SubmitWeixin(name){
                this.editLoading = true;
                let para = Object.assign({},this.weixin_msg)
                console.log(para)
                company_weixin_put(para).then(res => {
                    this.begCode (res.code);
                    if (res.code == 0) {
                        this.editLoading = false;
                        //NProgress.done();
                        this.$message({
                            message: '修改成功',
                            type: 'success'
                        });
                        this.getUsers();
                        if(name == 'AppKey'){
                            this.AppKeyDisabled = true;
                            this.AppKeyVisible = false
                        }else
                        if(name == 'SecretKey2'){
                            this.SecretKey2Disabled = true;
                            this.SecretKey2Visible = false
                        }else
                        if(name == 'templateId'){
                            this.templateIdDisabled = true;
                            this.templateIdVisible = false
                        }else
                        if(name == 'mpName'){
                            this.mpNameDisabled = true;
                            this.mpNameVisible = false
                        }else
                        if(name == 'templateId2'){
                            this.templateId2Disabled = true;
                            this.templateId2Visible = false
                        }else
                        if(name == 'templateId3'){
                            this.templateId3Disabled = true;
                            this.templateId3Visible = false
                        }else
                        if(name == 'templateId4'){
                            this.templateId4Disabled = true;
                            this.templateId4Visible = false
                        }
                    }
                })
            },
            handleAvatarSuccess(res, file) {
                console.log(file.type);
                this.platlogo.remark = res.data.path;
                this.Submit('平台Logo')
            },
            mpQrcodeSuccess(res, file){
                console.log(res);
                console.log(file);
                this.weixin_msg.mpQrcode = res.data.path
                this.SubmitWeixin()
            },
            beforeAvatarUpload(file) {
                console.log(file)
                const isJPG = file.type === 'image/jpeg';
                const isPNG = file.type === 'image/png';
                const isGIF = file.type === 'image/gif';
                let tp = false;
                if (isJPG) {
                    tp = isJPG;
                } else if (isPNG) {
                    tp = isPNG
                } else if (isGIF) {
                    tp = isGIF
                } else {

                }
                const isLt2M = file.size / 1024 / 1024 < 1;
                if (!isJPG && !isPNG && !isGIF) {
                    this.$message.error('上传头像图片只能是 JPG,GIF,PNG 格式!');
                }
                if (!isLt2M) {
                    this.$message.error('上传头像图片大小不能超过 1MB!');
                }
                return tp && isLt2M;
            },
            checkLicense(){
                this.editlicenseVisible = true
                let para = {
                    pageNo: 1,
                    pageSize: 10,
                }
                license_query(para).then((res) => {
                    console.log(res)
                    this.licenseText = res.data
                })
            },
            editSubmit(){
                this.editLoading = true
                let para = {
                    data: this.licenseText
                }
                license_edit(para).then((res) => {
                    console.log(res)
                    this.editLoading = false
                    if(res.code == 500){
                        this.$message({
                            message: res.message,
                            type:'warning'
                        })
                    }else{
                        this.$message({
                            message: '上传成功',
                            type:'success'
                        })
                        this.editlicenseVisible = false
                    }
                })
            }
        },
        mounted(){
            this.getUsers()
            let para = {
                pageNo: 1,
                pageSize: 10,
            }
            get_certificate(para).then((res) => {
                // console.log(res)
                this.stateText = res.data.stateText
                this.userName = res.data.userName
                this.licsn = res.data.clientSn
                this.exptime = res.data.expData
                this.licdevmax = res.data.maxClients
            })
            company_weixin_my(para).then(res => {
                console.log(res)
                this.weixin_msg = res.data
            })
        }
    }
</script>

<style >
.pb-icon{
    vertical-align:middle;
}
.confirm{
  background-color:#ecf5ff; 
  color: #409eff;
  margin-left: 5px;
  padding: 5px 8px;
  cursor: pointer;
  border-radius: 5px;
}
.confirm:hover{
  background-color:#409eff;
  color: #fff;
}    
.avatar-uploader-icon {
        font-size: 28px;
        color: #8c939d;
        width: 178px;
        height: 178px;
        line-height: 178px;
        text-align: center;
    }
.avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .other-setting{
    width: 49%;
    display: inline-block;
    margin-top: 15px;
  }
  .other-setting-title{
    margin-bottom: 10px;
  }
</style>

